package com.spicdt.edge.protocol.door.demo.model;

import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@Data
public class SrcResult {
    private String code;
    private String msg;
    private Object body;
    private String appToken;
    private String unixTimestamp;

    public SrcResult() {

    }

    public SrcResult(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public SrcResult(String code, String msg, Object body) {
        this.code = code;
        this.msg = msg;
        this.body = body;
    }


    public static SrcResult success(Object data) {
        return success("操作成功", data);
    }

    public static SrcResult success(String message, Object data) {
        return new SrcResult("200", message, data);
    }

    public static SrcResult error() {
        return error("操作失败");
    }

    public static SrcResult error(String msg) {
        return error("500", msg);
    }

    public static SrcResult error(String code, String msg) {
        return new SrcResult(code, msg, null);
    }


    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getBody() {
        return body;
    }

    public void setBody(Object body) {
        this.body = body;
    }

    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("code", getCode())
                .append("message", getMsg())
                .toString();
    }
}
